package com.sc;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.IOException;
import java.util.zip.GZIPInputStream;

public class Demo3 {

    public static void main(String[] args) {
//        String s = "1F8B08000000000000008BAE56CA4BCC4D55B2527AB6B5FBC5FAA94F763428E928E595E626A51601050D8C2D0D15CC0CCC148C4C4DCC8112C945A98925A92599601D79A539394A3AB53A0A70335E344E79BE79F7935DBB90CD3034365130B530B35430B730B7206CC6D3DEBE273B763D5DB7E8D99C5E64634C0C0C2C8C41C880B01910BF18216B27DE13B080E844D66E61660844C666162696A66638CC880500F70649D54D010000";
//        String s = "1F8B080000000000000095D0BD4A03411007F05719B635C57ECCEECEFA2A6211E50A21B92224950882A4F0235649214911B4108B7895B22C822F737B5EDEC28D20DC89E0C90C4C31CC8F3F7370CAF2FE3063FBAC7AB9AE8B45E92FE3D59A0CEBB17C323CCA4669B347068426B09A100C3A9596C7A3AC3FCEC6275FA7F9643060673DF861C5E92686C76A159A18171C844402D4243B42A60C3729156F3B29152A74FF4AB45C6EE7777551342521156A63C975444A7FF1F114AAF55B0B515268EB144801A22B14E6F5EB74BB786F43E93196AC46B32BF33D3A873BAF360FD1FBB6A9C1126A4067E84F28CE6E4B1FE2F37DB59A3515E49CD4AEF9EFC4E127D8E72A484C020000";
        String s = "1F8B080000000000000095924F4BC33014C0BF4AE8D51D9AE4BDE4D5AF221EA6F4206C3B8CED2482A005FF4D0F76826C87A10EF13077729422FA659AAEFB16A68AB00CA19584E4107EBFF7276FE7D0EB34DBA1B7EDE56F97C57C9825E7E66242CA6B789D7E7B2FECDA972D528C23318D044C4120EDE37E376CF6C2DEC137DAE9B75ADE51836DB84C3433E9733E4ED7653EF71917400C90444D91CAD22B9B95EF7A6C562021F85746A3D12ABE2FE6F37513171250690A2A25E6E96E194F1D56721B1F3593C06BE6902527CB97349FBCBB1EC151079209CEAA4566BA7061CB49F17354C337B10B83D065099224D856EABABDCCD2B85844ABE1E7860D499346ABB24BFD5EB57B739CCF1E4D92B84E649A0019048AAACBBB753F08ED94082EEDB869AC84B38F5307D6E588711B59D5684B71163930115308B29CF6EAC866709D25A9797DC8C783750BF83EC972FB7F2B76BF0063AD0903C1030000";
//        String s1 = "1f8b08000000000000138dd0b10e82301006e077e9a40998b650286e1807a27173d2385439b0a1b4a4a08931bebb95c1808361bdbbffcb9f3b3e911635a025da98ab4e9b46410b90230fe95b7d06eb169c73c618a184bae9c582e8a0937d8462cc7d4c7d12a297f785d6e22ef3bd782863878c332282a3284ea6325a82ca64594add0ea15988f9dc69017381495426747510953545b15b8ca818c71f8a703691daba831528352e44585f284ad83425d55a64c29a9fff304a390d837fc6e90d290c32a2b1010000";
        byte[] b = toByte(s);
        try {
            byte[] b1 = decompress(b);
            String str= new String (b1);
            System.out.println(str);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    /**
     * @param data
     * @return
     */
    public static byte[] decompress(byte[] data) throws IOException {
        ByteArrayOutputStream buffer = null;
        GZIPInputStream gzipInputStream = null;
        try {
            buffer = new ByteArrayOutputStream();
            gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(data));
            int n;
            byte[] _buffer = new byte[1024 * 12];
            while (-1 != (n = gzipInputStream.read(_buffer))) {
                buffer.write(_buffer, 0, n);
            }
            return buffer.toByteArray();
        } finally {
            closeQuietly(gzipInputStream);
            closeQuietly(buffer);
        }
    }

    private static void closeQuietly(Closeable closeable) {
        try {
            if (closeable != null) {
                closeable.close();
            }
        } catch (IOException ioe) {
            // ignore
        }
    }

    public static byte[] toByte(String hexString) {
        int len = hexString.length() / 2;
        byte[] result = new byte[len];
        for (int i = 0; i < len; i++)
            result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2), 16).byteValue();
        return result;
    }
}
